# load packages used in this example
library(sifr)
library(sf)
library(mapview)
In this example, I provided some example usage for the
sifr package. Some sociodemographic and built environment
variables are calculated for a small random sample of schools in
Toronto. Throughout this example, I used projection NAD83 / UTM zone
18N.
All types of School Locations in Toronto
# school locations in Toronto
schools <- st_read("./../extdata/toronto_schools.gpkg")
## Reading layer `School locations-all types data - 4326' from data source `C:\Users\zehui\Desktop\Materials\Personal_docs\sifr\extdata\toronto_schools.gpkg' using driver `GPKG'
## Simple feature collection with 1194 features and 24 fields
## Geometry type: MULTIPOINT
## Dimension: XY
## Bounding box: xmin: -79.61918 ymin: 43.59022 xmax: -79.13372 ymax: 43.83037
## Geodetic CRS: WGS 84
# to force the geometry column to name geometry
st_geometry(schools) <- "geometry"
# for reproductivity
set.seed(123)
# take a random 30 sample to simplify calculation as this is just a example
schools <- schools[sample(1:nrow(schools), 30),]
mapview(schools)
Some variables of interest
# road intersections in Toronto
intersections <- st_read("./../extdata/centreline_intersection.gpkg")
## Reading layer `Centreline Intersection - 4326' from data source `C:\Users\zehui\Desktop\Materials\Personal_docs\sifr\extdata\centreline_intersection.gpkg' using driver `GPKG'
## Simple feature collection with 55149 features and 20 fields
## Geometry type: MULTIPOINT
## Dimension: XY
## Bounding box: xmin: -79.63926 ymin: 43.581 xmax: -79.11545 ymax: 43.85545
## Geodetic CRS: WGS 84
# to force the geometry column to name geometry
st_geometry(intersections) <- "geometry"
# road centrelines in Toronto
roads <- st_read("./../extdata/centreline.gpkg")
## Reading layer `Centreline - Version 2 - 4326' from data source `C:\Users\zehui\Desktop\Materials\Personal_docs\sifr\extdata\centreline.gpkg' using driver `GPKG'
## Simple feature collection with 71297 features and 40 fields
## Geometry type: MULTILINESTRING
## Dimension: XY
## Bounding box: xmin: -79.63926 ymin: 43.5809 xmax: -79.11545 ymax: 43.85545
## Geodetic CRS: WGS 84
# to force the geometry column to name geometry
st_geometry(roads) <- "geometry"
# 2021 Canadian census data
census_data <- readRDS("./../data/census_data.rds")
# land use data in Toronto
landuse <- st_read("./../extdata/landuse.shp")
## Reading layer `landuse' from data source `C:\Users\zehui\Desktop\Materials\Personal_docs\sifr\extdata\landuse.shp' using driver `ESRI Shapefile'
## Simple feature collection with 12723 features and 33 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 7201961 ymin: 918078.1 xmax: 7243302 ymax: 954703.3
## Projected CRS: PCS_Lambert_Conformal_Conic
mapview(landuse, zcol="Class_name")